package com.briup.cms.service.impl;

import com.briup.cms.bean.BaseLog;
import com.briup.cms.dao.BaseLogExtendMapper;
import com.briup.cms.dao.BaseLogMapper;
import com.briup.cms.exception.CustomerException;
import com.briup.cms.service.IBaseLogService;
import com.briup.cms.utils.MessageStatus;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jdk.nashorn.internal.ir.FunctionNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseLogServiceImpl implements IBaseLogService {
    @Autowired
    private BaseLogExtendMapper logmapper;
    @Autowired
    private BaseLogMapper mapper;
    private BaseLog baselog;

    @Override
    public PageInfo<BaseLog> findAll(int pageNum, int pageSize) throws CustomerException {
        PageHelper.startPage(pageNum,pageSize,true);
        List<BaseLog> list=logmapper.findAllLog();
        PageInfo<BaseLog>pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void deleteById(long id) throws CustomerException {
        BaseLog baseLog=mapper.selectById(id);
        if(baseLog==null){
            throw new CustomerException(MessageStatus.SPECIFIED_QUESTIONED_ADNIN_FORBID_DEL);
        }
        this.mapper.deleteById(id);
    }
}
